/* RMORPG - Client.cpp
   Copyright (c) 2007, Michael Borgmann <code@lechuck.de>
   This code is released under the GNU Public License (GPL)
 */

#include <iostream>
#include <Socket.h>

using namespace std;
using namespace rmorpg;

int main() {
	
	// About RMORPG Client
	cout << "RMORPG Test Client\n" << endl;
	cout << "Copyright (c) 2007, "
	     << "Michael Borgmann <code@lechuck.de>" << endl;
	cout << "This project is released under the GNU Public License (GPL)\n"
	     << endl;

	Socket connection;

/*	cout << "xxx.xxx.xxx.xxx = "
	     << connection.DNSLookup("xxx.xxx.xxx.xxx") << endl;
	cout << "www.lechuck.de = "
	     << connection.DNSLookup("www.lechuck.de" << endl;
*/
	cout << "Create TCP Socket ... ";
	if (connection.CreateTCPSocket()) cout << "yes\n";
	else cout << "no\n";

	cout << "Connect to Server ... ";
	if (connection.Connect("www.lechuck.de", 6666)) cout << "yes\n";
	else cout << "no\n";

	bool done = false;
	char message[128];
	cout << "%: " << endl;

	while (!done) {
		cin.getline(message, 128);

		if (connection.Send(message,strlen(message) + 1))
			cout << strlen(message) + 1 << " Byte(s) send" << endl;
		else cout << "Message not send!" << endl;

		if (strcmp(message, "servquit") == 0)
			done = true;
	}

}
